﻿using System;
using System.Threading.Tasks;
namespace iTPS.Service.Core.TaskContrib
{
    public static class TaskExtension
    {
        public static void AsyncNoWaitOnlyOnFaulted(this Task task, Action<Exception> exceptionHandler = null)
        {
            task.ContinueWith(result =>
            {
                exceptionHandler?.Invoke(result.Exception);
            }, TaskContinuationOptions.OnlyOnFaulted);

            //task.Start();
        }

        //public static void AsyncNoWait(this Task task, Action<Task> continueHandler, TaskContinuationOptions taskContinuationOptions)
        //{
        //    task.ContinueWith(continueHandler, taskContinuationOptions);
        //}
    }
}
